import {useEffect, useState} from 'react';
import { getChannelListApi } from '@/apis/article';
function useChannel(){
    const [channelListData, setchannelListData] = useState([])
    useEffect(() => {
        // 封装函数，在函数体内调用接口
        const getChannelList = async () => {
            const res = await getChannelListApi()
            setchannelListData(res.data.channels.map(item => ({ label: item.name, value: item.id })))
        }
        // 调用
        getChannelList()
    }, [])
    return channelListData
}
export {useChannel}